﻿<%@ WebHandler Language="C#" Class="CoverPageHandler" %>

using System;
using System.Web;
using System.IO;
using System.Data;
using System.Text;
using System.Collections;
using System.Data.SqlClient;

using CE.Database;
using CE.InputOut;
public class CoverPageHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.Clear();

        if (context.Request["fileName"] != null)
        {
            string _filePath = context.Request.QueryString["fileName"].ToString();

            string filePath = _filePath.Replace("|", "\\");
            FileInfo file = new System.IO.FileInfo(filePath);
            if (!file.Exists)
            {
                context.Response.StatusCode = 500;
                context.Response.End();
                return;
            }
          
            //Set the appropriate ContentType.
            context.Response.ContentType = "Application/pdf";
            //Get the physical path to the file.
            string FilePath = file.FullName;
            //Write the file directly to the HTTP content output stream.
            context.Response.WriteFile(FilePath);
            context.Response.End();

        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}